﻿{include file="public/header"}
<title>店长列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 合伙人管理
    <span class="c-gray en">&gt;</span> 个人合伙人列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form method="get">
        <div class="ch-c">
            <div class="ch-form-row">
                <p>注册时间:</p>
                <input type="text" name="start_time" id="countTimestart" onfocus="selecttime(1)" size="17" class="date" 
                readonly value="<?php echo isset($data['start_time'])?$data['start_time']:''?>">
                <b>-</b>
                <input type="text" name="end_time" id="countTimeend" onfocus="selecttime(2)" size="17" class="date" 
                readonly value="<?php echo isset($data['end_time'])?$data['end_time']:''?>">
            </div>
            <select name="num" class="ch-form-cSelect">
                <option value=" ">请选择公司</option>
                {volist name='res' id='v'}
                <option value="{$v.personal_id}">{$v.username}</option>
                {/volist}
            </select>
            <input type="text" name="mobile" placeholder=" 账号" class="ch-form-assignor" value="<?php echo isset($data['mobile'])?$data['mobile']:''?>">
            <input type="text" name="username" placeholder=" 昵称" class="ch-form-assignor" value="<?php echo isset($data['username'])?$data['username']:''?>">
            <button class="btn btn-success" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
    </form>
    <div class="ch-row">
        <a class="ch-button ch-blue add "  href="javascript:;" title="新增">新增</a>
    </div>
    <div class="mt-20">
        <div class="title-border">
            <div class="flex1 screen-phone">序号</div>
            <div class="flex2">昵称</div>
            <div class="flex3">电话</div>
            <div class="flex1 screen-phone">性别</div>
            <div class="flex3 screen-phone">注册时间</div>
            <div class="flex3 screen-phone">登录时间</div>
            <div class="flex2 screen-phone">当前状态</div>
            <div class="flex2 screen-phone">累计登陆</div>
            <div class="flex2 screen-phone">剩余金额</div>
            <div class="flex2 screen-phone">所属集团</div>
            <div class="flex1">等级</div>
            <div class="flex3">操作</div>
        </div>
        {volist name='list' id='vo'}
        <div class="content-border">
            <div class="flex1 screen-phone">{$vo.personal_id}</div>
            <div class="flex2">{$vo.username}</div>
            <div class="flex3">{$vo.mobile}</div>
            <div class="flex1 screen-phone">
                {if condition="$vo.sex == 0"} 保密
                {elseif condition="$vo.sex == 1"/}男
                {elseif condition="$vo.sex == 2"/}女
                {/if}
            </div>
            <div class="flex3 screen-phone">{:date('Y-m-d H:i:s',$vo.created_time)}</div>
            <div class="flex3 screen-phone">{:date('Y-m-d H:i:s',$vo.last_login_time)}</div>
            <div class="flex2 screen-phone">
                {if condition="$vo.status == 0"} 正常
                {elseif condition="$vo.status == 1"/}禁用
                {elseif condition="$vo.status == 2"/}删除
                {/if}
            </div>
            <div class="flex2 screen-phone">{$vo.days}</div>
            <div class="flex2 screen-phone">{$vo.sheng}</div>
            <div class="flex2 screen-phone">{$vo.num}</div>
            <div class="flex1">
                {if condition="$vo.grade == 0"} 普通
                {elseif condition="$vo.grade == 1"/}高级
                {elseif condition="$vo.grade == 2"/}钻石
                {/if}
            </div>
            <div class="flex3 screen-pc"><a href="javascript:;" class="ch-button ch-blue more">查看更多</a></div>
            <div class="flex3 screen-phone">
                {if condition="$vo.status == 0"}
                <a class="ch-button ch-blue edit" data-id="{$vo.personal_id}" href="javascript:;" title="编辑">编辑</a>
                <a class="ch-button ch-red disable" data-id="{$vo.personal_id}" data-status="1" href="javascript:;" title="禁用">禁用</a>
                {/if}

                {if condition="$vo.status == 1"}
                <a class="ch-button ch-green disable" data-id="{$vo.personal_id}" data-status="0" href="javascript:;" title="启用">启用</a>
                <a class="ch-button ch-blue edit" data-id="{$vo.personal_id}" href="javascript:;" title="编辑">编辑</a>
                {/if}

                <a class="ch-button ch-red del" data-id="{$vo.personal_id}" href="javascript:;" title="删除">删除</a>
                <a class="ch-button ch-gray hui" data-id="{$vo.personal_id}" href="javascript:;" title="删除">设置等级</a>
            </div>
        </div>
        {/volist}
        <div class="pages" style="float: right">{$list->render()}</div>
    </div>
    <div class="ch-more">
        <div class="ch-more-box">
            <div class="ch-more-top">
                <div class="ch-more-off"></div>
            </div>
            <div class="ch-more-tark">
                <div class="ch-more-content">
                    
                </div>
            </div>
        </div>
    </div>
</div>

{include file="public/footer"}
<script type="text/javascript">
    var winWidth = $(window).width();
    var areaWidth = "";
    var areaHeight = "";
    function selecttime(flag) {
        if (flag == 1) {
            var endTime = $("#countTimeend").val();
            if (endTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', maxDate: endTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        } else {
            var startTime = $("#countTimestart").val();
            if (startTime != "") {
                WdatePicker({dateFmt: 'yyyy-MM-dd', minDate: startTime})
            } else {
                WdatePicker({dateFmt: 'yyyy-MM-dd'})
            }
        }
        
    }
    /**
     * 编辑
     */
     $('.page-container').on('click','.edit',function () {
        if( winWidth > 768 ){
            areaWidth = "500px"
            areaHeight = "600px"
        } else {
            areaWidth = '90%'
            areaHeight = '90%'
        }
        var id = $(this).attr('data-id');
        var src="{:Url('index/personal/edit')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            scrollbar: true ,//屏蔽浏览器滚动条
            shade: 0.4,
            title: '编辑合伙人',
            content: src+'?personal_id='+id
        });
    });




    /**
     * 禁用/启用
     */
    $('.page-container').on('click','.disable',function () {
        var id=$(this).attr('data-id');
        var status=$(this).attr('data-status');
        var obj={};
        obj.personal_id=id;
        obj.status=status;
        var str='确认要启用该用户吗？';
        if(status==1){
            str='确认要禁用该用户吗？';
        }
        var src="{:Url('index/personal/disable')}";
        layer.confirm(str, function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (res) {
                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:3000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });

    /**
     * 删除
     */
    $('.page-container').on('click','.del',function () {
        var id=$(this).attr('data-id');
        var obj={};
        obj.personal_id=id;
        var src="{:Url('index/personal/del')}";
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'POST',
                url: src,
                dataType: 'json',
                data: obj,
                success: function (data) {
                    console.log(data);
                    var res=JSON.parse(data);

                    if(res.code==200){
                        layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                            setTimeout("window.location.reload()", 1);
                        });
                    }else{
                        layer.msg(res.msg,{icon: 5,time:1000});
                    }

                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    });
    /**
     * 添加
     */
    $('.add').click(function () {
        if( winWidth > 768 ){
            areaWidth = "500px"
            areaHeight = "600px"
        } else {
            areaWidth = '90%'
            areaHeight = '90%'
        }
        var id = $(this).attr('data-id');
        var src="{:Url('index/personal/add')}";
        layer.open({
            type: 2,
            area: [areaWidth, areaHeight],
            title: '添加合伙人',
            content: src

        });

    });
    /**
     * 设置等级
     */
    $('.page-container').on('click','.hui',function () {
        if( winWidth > 768 ){
            areaWidth = "500px"
            areaHeight = "200px"
        } else {
            areaWidth = '90%'
            areaHeight = '200px'
        }
        var id = $(this).attr('data-id');

        var src = "{:Url('index/personal/hui')}";
        layer.open({
            type: 1,
            title: '设置',

            area: [areaWidth, areaHeight],
            content:`
                <div class="ch-row ch-info-form" style='margin-top: 30px; padding: 0 20px;'>
                    <div class="flex1">等级：</div>
                    <div class="flex2">
                        <select class="form-control grade" name="grade">
                            <option  value="0">普通</option>
                            <option  value="1">高级</option>
                            <option value="2">钻石</option>
                        </select>
                    </div>
                </div>
            `,

            btn:['保存','取消'],
            btn1: function (index,layero) {
                $.ajax({
                    type: 'POST',
                    url: src,
                    dataType: 'json',
                    data: {
                     order_id: id,
                        grade:$('.grade').val()

                    },
                    success: function (data) {
                        var res = JSON.parse(data);
                        if (res.code == 200) {
                            layer.msg(res.msg, {icon: 1, time: 2000}, function () {
                                setTimeout("window.location.reload()", 1);
                            });
                        } else {
                            layer.msg(res.msg, {icon: 5, time: 1000});
                        }

                    },
                    error: function (data) {
                        console.log(data);
                    },
                });

            },
            btn2: function (index, layero) {
                layer.close(index);
            }

        });
    });

</script>
</body>
</html>